﻿<%@ Page Language="C#" MasterPageFile="~/PageDefault.Master" AutoEventWireup="true" CodeBehind="colaborador.aspx.cs" Inherits="SPM.colaborador.WebForm1" Title=" Manutenção de Colaboradores " %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<center><h4>Manutenção de Colaboradores</h4></center>    
    <asp:GridView ID="GridView1" 
                  runat="server"
                  AllowPaging="True" 
                  DataKeyNames="cpf_cnpj"
                  AllowSorting="True"
                  AutoGenerateColumns="False"
                  EmptyDataText="Nenhum colaborador encontrado." 
                  OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
                  HorizontalAlign="Center" 
                  PageSize="5" BackColor="White" BorderColor="#E7E7FF" 
                  BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal"
                  DataSourceID="SqlDataSource1">
                  
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />          
        <Columns>
            <asp:BoundField DataField="idColaborador" HeaderText="ID" SortExpression="idColaborador" />
            <asp:BoundField DataField="cpf_cnpj" HeaderText="CPF/CNPJ" SortExpression="cpf_cnpj" />
            <asp:BoundField DataField="nome_razao" HeaderText="Nome/Razão" SortExpression="nome_razao" />
            <asp:BoundField DataField="telefone" HeaderText="Fone" SortExpression="telefone" />
            <asp:CommandField HeaderText="Exibir" SelectText="Exibir" ShowHeader="True" 
                ShowSelectButton="True" ShowDeleteButton="True" />
        </Columns>
        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
        <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
        <HeaderStyle BackColor="Gray" Font-Bold="True" ForeColor="Black" 
            Font-Size="Medium" />
        <AlternatingRowStyle BackColor="#F7F7F7" />
    </asp:GridView>
    <br /> <br />
    <asp:FormView ID="FormView1"
                  runat="server"
                  DataKeyNames="cpf_cnpj" 
                  DataSourceID="SqlDataSource1"
                  EmptyDataText="Nenhum Colaborador selecionado."
                  Height="72px" HorizontalAlign="Center"
                  DefaultMode="Insert" BackColor="White" BorderColor="#E7E7FF" 
                  BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal">
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
        <EditItemTemplate>
            <table cellpadding="0" cellspacing="0">
                <tr>
                    <td>ID:</td>
                    <td><asp:Label ID="LBIdColaborador" runat="server" Text='<%# Eval("idColaborador") %>' /></td>
                </tr>
                <tr>
                    <td>CPF/CNPJ:</td>
                    <td><asp:Label ID="LBCpf_cnpj" runat="server" Text='<%# Eval("cpf_cnpj") %>' /></td>
                </tr>
                <tr>
                    <td>Nome/Razão:</td>
                    <td><asp:TextBox ID="TXBbNome_razao" runat="server" MaxLength="50" Text='<%# Bind("nome_razao") %>' /></td>
                </tr>
                <tr>
                    <td>Telefone:</td>
                    <td><asp:TextBox ID="TXBTelefone" runat="server" MaxLength="12" Text='<%# Bind("telefone") %>' /></td>
                </tr>
                <tr>
                    <td>Observacao:</td>
                    <td><asp:TextBox ID="TXBObservacao" runat="server" Text='<%# Bind("observacao") %>' /></td>
                </tr>
                <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
                <tr>
                    <td colspan="2">
                        <center>
                            <asp:LinkButton ID="UpdateButton"
                                runat="server"
                                CausesValidation="True" 
                                CommandName="Update" Text="Atualizar" />
                            &nbsp;
                            <asp:LinkButton ID="UpdateCancelButton" 
                                            runat="server" 
                                            CausesValidation="False" 
                                            CommandName="Cancel" 
                                            Text="Cancelar" />
                        </center>
                    </td>
                </tr>
            </table>
        </EditItemTemplate>
        <InsertItemTemplate>
            <table cellpadding="0" cellspacing="0">
                <tr>
                    <td>CPF/CNPJ*:</td>
                    <td><asp:TextBox ID="TXBCpf_cnpj" runat="server" MaxLength="13" Text='<%# Bind("cpf_cnpj") %>' /></td>
                    
                </tr>
                <tr>
                    <td>Nome/Razão*:</td>
                    <td><asp:TextBox ID="TXBNome_razao" runat="server" MaxLength="50" Text='<%# Bind("nome_razao") %>' /></td>
                </tr>
                <tr>
                    <td>Telefone:</td>
                    <td><asp:TextBox ID="TXBTelefone" runat="server" MaxLengt="12" Text='<%# Bind("telefone") %>' /></td>
                </tr>
                <tr>
                    <td> Observacao:</td>
                    <td><asp:TextBox ID="TXBObservacao" runat="server" Text='<%# Bind("observacao") %>' /></td>
                </tr>
                <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
                <tr>
                    <td colspan="2">
                        <center>
                            <asp:LinkButton ID="InsertButton"
                                            runat="server"
                                            CausesValidation="True" 
                                            CommandName="Insert" Text="Inserir" />
                            &nbsp;
                           <asp:LinkButton ID="InsertCancelButton"
                                           runat="server" 
                                           CausesValidation="False"
                                           CommandName="Cancel"
                                           Text="Cancelar" />
                        </center>
                    </td>
                </tr>
            </table>
        </InsertItemTemplate>
        <ItemTemplate>
            ID*:
            <asp:Label ID="LBIdColaborador" runat="server" Text='<%# Eval("idColaborador") %>' />
            <br />
            CPF/CNPJ*:
            <asp:Label ID="cpf_cnpjLabel" runat="server" Text='<%# Eval("cpf_cnpj") %>' />
            <br />
            Nome/Razão*:
            <asp:Label ID="LBLNome_razao" runat="server" Text='<%# Bind("nome_razao") %>' />
            <br />
            Telefone:
            <asp:Label ID="telefoneLabel" runat="server" Text='<%# Bind("telefone") %>' />
            <br />
            Observacao:
            <asp:Label ID="LBObservacaoLabel" runat="server" Text='<%# Bind("observacao") %>' />
            <br />
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
                Text="Editar" />
            &nbsp;
            <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
                Text="Excluir" />
            &nbsp;
            <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
                Text="Novo" />
        </ItemTemplate>        
        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
        <EditRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
    </asp:FormView>
    <asp:SqlDataSource ID="SqlDataSource1"
                       runat="server" 
                       ConnectionString="<%$ ConnectionStrings:SPM %>" 
                       SelectCommand="SELECT * FROM [colaborador]"   
                       InsertCommand="INSERT INTO colaborador VALUES (@cpf_cnpj, @nome_razao, @telefone, @observacao)"
                       UpdateCommand="UPDATE colaborador SET cpf_cnpj = @cpf_cnpj, nome_razao = @nome_razao, telefone = @telefone, observacao = @observacao WHERE (cpf_cnpj = @cpf_cnpj)"
                       DeleteCommand="DELETE FROM colaborador WHERE (cpf_cnpj = @cpf_cnpj)" >
        <DeleteParameters>
            <asp:Parameter Name="cpf_cnpj" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="cpf_cnpj" />
            <asp:Parameter Name="nome_razao" />
            <asp:Parameter Name="telefone" />
            <asp:Parameter Name="observacao" />      
            <asp:Parameter Name="idColaborador" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="cpfCnpj" />
            <asp:Parameter Name="nomeRazao" />
            <asp:Parameter Name="telefone" />
            <asp:Parameter Name="observacao" />      
        </InsertParameters>                    
    </asp:SqlDataSource>

    
</asp:Content>
